package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.PlanSetAggService;
import com.todo.strategy.online.iface.PlanSetFrontendIface;
import com.todo.strategy.online.iface.request.*;
import com.todo.strategy.online.iface.response.PlanSetInfoVO;
import com.todo.strategy.online.iface.response.RecentlyPlanSetVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/19 14:30
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "计划清单前台接口", description = "计划清单前台接口")
public class PlanSetFrontendController implements PlanSetFrontendIface {

    @Resource
    private PlanSetAggService planSetAggService;


    @Override
    @Operation(summary = "新增计划清单信息")
    @PostMapping("/insertPlanSet")
    public BizResponse<Boolean> insertPlanSet(InsertPlanSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planSetAggService.insertPlanSet(param);
    }

    @Override
    @Operation(summary = "删除计划清单信息")
    @PostMapping("/removePlanSet")
    public BizResponse<Boolean> removePlanSet(RemovePlanSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planSetAggService.removePlanSet(param);
    }

    @Override
    @Operation(summary = "更新计划清单信息")
    @PostMapping("/updatePlanSetById")
    public BizResponse<Boolean> updatePlanSetById(UpdatePlanSetParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planSetAggService.updatePlanSetById(param);
    }

    @Override
    @Operation(summary = "根据用户id查询计划清单信息")
    @PostMapping("/queryPlanSetByUser")
    public BizPageResponse<PlanSetInfoVO> queryPlanSetByUser(QueryPlanSetByUserParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return planSetAggService.queryPlanSetByUser(param);
    }

    @Override
    @Operation(summary = "查询用户最近相关计划清单【前后各一周时间】")
    @PostMapping("/queryRecentlyPlanSetList")
    public BizResponse<RecentlyPlanSetVO> queryRecentlyPlanSetList(QueryRecentlyPlanSetListParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planSetAggService.queryRecentlyPlanSetList(param);
    }
}
